import request from "@/request";

export default {
  // 供应信息列表
  getSupplyList(params) {
    return request({
      url: "/customer/supply/list",
      method: "get",
      params,
    });
  },

  // 添加供应信息
  addSupply(data) {
    return request({
      url: "/supply",
      method: "post",
      data,
    });
  },

  // 普通供应信息列表
  getSupplyNormalList(params) {
    return request({
      url: "/supply/list",
      method: "get",
      params,
    });
  },

  // 供应信息详情
  getSupplyDetail(id) {
    return request({
      url: `/customer/supply/${id}`,
      method: "get",
    });
  },

  // 需求信息列表
  getDemandList(params) {
    return request({
      url: "/customer/demand/list",
      method: "get",
      params,
    });
  },

  // 需求信息详情
  getDemandDetail(id) {
    return request({
      url: `/customer/demand/${id}`,
      method: "get",
    });
  },

  // 申请资源
  applySupply(data) {
    return request({
      url: "/resource/order",
      method: "post",
      data,
    });
  },

  // 取消申请
  cancelApply(id) {
    return request({
      url: "/resource/order/cancel",
      method: "put",
      data: { id },
    });
  },

  // 创建需求
  createDemand(data) {
    return request({
      url: "/demand",
      method: "post",
      data,
    });
  },

  // 更新需求
  updateDemand(data) {
    return request({
      url: "/demand",
      method: "put",
      data,
    });
  },

  // 创建供应
  createSupply(data) {
    return request({
      url: "/supply",
      method: "post",
      data,
    });
  },

  // 更新供应
  updateSupply(data) {
    return request({
      url: "/supply",
      method: "put",
      data,
    });
  },

  // 切换供应状态
  toggleSupply(data) {
    return request({
      url: "/supply/updateStatus",
      method: "put",
      data,
    });
  },

  // 检查完整手机号
  checkCompletePhone(params) {
    return request({
      url: "/demand/mobileSearch",
      method: "get",
      params,
    });
  },

  // 切换需求状态
  toggleDemand(data) {
    return request({
      url: "/demand/updateStatus",
      method: "put",
      data,
    });
  },

  // 申请合作
  applyDemand(params) {
    return request({
      url: "/cooperation/supply",
      method: "post",
      params,
    });
  },

  // 获取供应信息的城市列表
  getSupplyCityList() {
    return request({
      url: "/customer/supply/citys",
      method: "get",
    });
  },

  // 获取需求信息的城市列表
  getDemandCityList() {
    return request({
      url: "/customer/demand/citys",
      method: "get",
    });
  },
};
